#pragma once

template<class iterator, class Ref, class Ptr>
class Reverse_iterator
{
	typedef Reverse_iterator<iterator, Ref, Ptr> Self;
public:
	Reverse_iterator(iterator it)
		:_it(it)
	{}


	Ref operator*()
	{
		iterator rit(_it);
		rit--;
		return *rit;
	}

	Ptr operator->()
	{
		iterator rit(_it);
		return rit.operator->();
	}

	Self& operator++()
	{
		_it--;
		return *this;
	}

	Self operator++(int)
	{
		Self tmp(_it);
		_it--;
		return tmp;
	}

	Self& operator--()
	{
		_it++;
		return *this;
	}

	Self operator--(int)
	{
		Self tmp(_it);
		_it++;
		return tmp;
	}

	bool operator==(const Self& s)
	{
		return _it == s._it;
	}

	bool operator!=(const Self& s)
	{
		return _it != s._it;
	}

private:
	iterator _it;
};